// components/info_panel/info_panel.js
import ajax from "../../utils/ajax.js";
let app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    itemdata:Object
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    to_detail(){
      console.log("跳转详情页")
      this.triggerEvent('handler', {type:'detail',id:4}, {})
    },
    to_bm(){
      console.log("直接报名");
      this.triggerEvent('handler', {type:'bm',id:4}, {})
    },
    shuaxin(){
      let data = {
        type:3,
        id:this.data.itemdata.id
      }
      console.log(data)
      ajax.post({
        url:'wx/pay',
        data
      }).then(res=>{
        if(res.code==1){
          app.toast(res.message)
        }
        wx.requestPayment({
          timeStamp: res.data.timeStamp,
          nonceStr: res.data.nonceStr,
          package: res.data.package,
          signType: res.data.signType,
          paySign: res.data.paySign,
          success(res) {
            console.log(res);
            app.toast("刷新成功", 'succ')
            
          },
          fail(res) {
            console.log(res)
    
          }
        })
      })
    },
    bianji(){
      app.toast("暂未开放 敬请期待")
    },
    zhiding(){
      app.toast("暂未开放 敬请期待")

    }
  },

})
